﻿using System;
using Fly.Data;

namespace FlyWebFrame.Model
{
    public class Courses:SqlServer
    {

        public Courses()
        {
            this.table = "courses";
            this.key = "id";
        }
        public int id;
        public int level;
        public string title;
        public string conditions;
        public int duration;
        public string functions;
        public string skills;
        public string descriptions;
        public string topics;
        public string attendant;
        public string benefit;
        public string code;
        public string link;

        public string viTitle;
        public string viDescription;
        public string viFunctions;
        public string viSkills;
        public string viTopics;
        public string viAttendant;
        public string viBenefit;

        public bool Add()
        {
            return this.Insert("level,conditions,duration,functions,skills,descriptions,topics,attendant,benefit,title,code").Status;
        }

        public bool Edit()
        {
            return this.Update("level,conditions,duration,functions,skills,descriptions,topics,attendant,benefit,title,code").Status;
        }

        public Result GetByIds(string ids) 
        {
            return this.Select("id IN ("+ids+")", null, null, null);
        }

        public Result Get()
        {
            return this.Select(null, null, "level ASC, code ASC", null);
        }

        public Result Get(int pageindex, int pagesize)
        {
            return this.Select(null, null, null, null, pageindex, pagesize);
        }
    }
}